﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NetDon.WebControls;
using NetDon.Utilities;

namespace NetDon.OA.Portal.Product
{
    public partial class VariationProductManagement : NetDonPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                PageQueryAdapter1.PerformQuery();

            }
        }



        protected void PageQueryAdapter1_PerformGetCondition(object sender, PerformGetConditionEventArgs e)
        {
            var criteria = new VariationProudctCriteria
            {

                Name = txtProductName.Text.Trim()

            };

            e.Condition = criteria;
        }

        protected void PageQueryAdapter1_PerformGetRecordCount(object sender, PerformGetRecordCountEventArgs e)
        {
            e.RecordCount = new VariationProductService().GetVariationProductCount((VariationProudctCriteria)e.Condition);
        }

        protected void PageQueryAdapter1_PerformGetPageData(object sender, PerformGetPageDataEventArgs e)
        {

            e.DataSource = new VariationProductService().SearchVariationProductByCondition((VariationProudctCriteria)e.Condition, gridCustomerInfoList.SortExpression,
                                                      gridCustomerInfoList.SortDirection, e.PageSize, e.PageIndex);
        }


        protected void btnReload_Click(object sender, EventArgs e)
        {
            PageQueryAdapter1.PerformQuery();
        }


        protected void btnSearch_Click(object sender, EventArgs e)
        {
            PageQueryAdapter1.PerformQuery();
        }

        protected void gridOrderList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var entity = (e.Row.DataItem);

                var orderId = e.Row.Attributes["Id"] = Convert.ToString(DataBinder.Eval(entity, "Id"));


            }
        }

        protected void btnDeleteDemand_Click(object sender, EventArgs e)
        {
          
               if(new VariationProductService().RemoveVariationProduct(fieldCustomerId.Value.ToInt32().Value))
               {
                   PageQueryAdapter1.PerformQuery();
                   Alert("删除成功!");
               }
               else
               {
                     Alert("删除失败！");
               }
          
              
            }

        }



 
}